Issue57 fix

Unit tests and a fix for #57.

I also fixed an issue I ran into with the database connections in the unit tests.