Updated source code, added test cases to cover http://tools.ietf.org/html/rfc6455#section-4.2.1