merged tests into server, fixed closing of some streams