Add connection_manager context manager and unit-tests around it