make test pass :/
factorize connection handling