Avoid double-close paths in http tests

Coverity spotted that there were some paths through the test
functions that would double-close some sockets.