Fix a memory leak and test timeout in websockets.

In some cases (primarily when prepare() is asynchronous), an
HTTP1ServerConnection could be left waiting forever for a connection
to finish when that connection has been detached and handed off to a
WebSocketHandler.  This would manifest as a leak and a timeout in
tests as the HTTPServer waited for all its existing connections to
finish.

Also fix a bug in the test tearDown method that would actually
wait forever for connections to finish instead of timing out.

Closes #1133.