some connection tests and an idea of refactoring