naive connection error handler
first naive unit tests
refactoring