Refactor server connection - prepare for testing, active handlers in session