Add tests for encoding