Refactoring/connect reconnect

Added `adapter.connect` functionality since it is called by jugglingdb. Refactored initialization function to reuse the code in `adapter.connect`.