encode/decode payload with tests.

TODO: supports on encode/decode payload as binary.