Clean-up the implementation a bit.
Start of some tests for reconnecting client.