add tests, fix pre-to-codec