Fixed integral encoding + tests.