Convert socket closes in tests to promises