public static IPacket SendMessage(string s)
 {
     var pack = new MutablePacket();
     pack.WriteShort(2); //OPCode
     pack.WriteStandardString(s);
     return pack;
 }
        public async Task TestPacketWriteUShort()
        {
            const int size = sizeof(ushort);
            const int lastIndex = size - 1;

            var packet = new MutablePacket();
            packet.WriteShort(98);
            var bytes = packet.Lock();
            Assert.IsTrue(bytes.Length >= size && (bytes[0] == 98 || bytes[lastIndex] == 98), "Failed to write unsigned short to packet");
            if (packet.Locked)
            {
                var task = new Task(() => packet.WriteUShort(1054));
                task.Start();
                Assert.IsTrue(await TaskTimesOut(TimeSpan.FromSeconds(2), task), "Packet reported being locked after locking but was still mutable");
            }

            else
            {
                bytes[0] = 127;
                var newBytes = packet.Lock();
                if (newBytes[0] != 98 && newBytes[lastIndex] != 98)
                    Assert.Fail("Packet reported not being locked but the buffer was returned by reference not copy. Return a full copy of the buffer if you wish to unlock else ensure you set the buffer to a locked state when Lock() is called.");
            }
        }