Fixed a bug in ManagedConnections test and moved condition variable notifications outside of locked scopes.