Fix up more tests to use stubbed objects.

Figured out the general strategy of mocking the db and am in the process
of fixing up more and more tests.