Refactored PostgreSQL unit testing functions. Added a couple of unit tests.