tests for encoding and decoding