Fixed websocket reconnect bug and sanitised some tests in the process.