Better application architecture for testing.

It should now be easier to mock out the database. This change caused all
unit tests to blow up though. They will be fixed soon.
Test cases updated (not yet fully functional).
Bump.