closing connections, fixing tests