Added some security checks in isHandshakePending

Should probably add another check to make sure that the host or origin field of the incoming handshake request matches the uri of the server.