Rewrite for reconnect with tests