Fix error when using postgres.
Update tests for postgres fix.
Merge pull request #246 from t-bullock/postgres-fix

Fix errors when using Postgres.