Code style and more unit tests on encode / decode