Generalize db methods.
Created pg test setup.
Added utils module.
Fixed pg sorting and added a bunch of tests.