`new WebSocket(uri, 'subprotocol')` sends Sec-WebSocket-Protocol header

This is a copy of #323, but with tests and with an old TODO removed. The tests are broken by the first commit in order to show that the second commit fixes them.

resolves #323
resolves #290
resolves #298

see #227