First working version of reconnecting client factory before test and refactoring.