Add function for decoding packet.
Add tests for encoding/decoding.