Python Context Managers

De-duplicating setup and cleanup