Replace the global db pointer with a hook that test cases can call to access
the shared database. The result is still global, but the name is a little more
self-documenting, and the use of call syntax makes it clear where we are
accessing something with more than trivial structure.