Implement basic encoding and decoding, test