Update tests for reconnection.

Add tests for reconnecting.
Small refactoring.