Added decodePacket method
Implemented encodePayload with tests