Fix postgres packing functions and add some tests.
Fix postgres support and add tests that make sure they don't break.