Fix bugs in WebSocket writeMessage

Signed-off-by: Julien Viet <julien@julienviet.com>
for now yes, these tests hangs for me and I need an expert to look at why. I investigated and it seems that the "close" frame is never sent to the client.