Db fixes

Support both direct DB connections and connections via fh.db

Make files more modular.
Have the mock fh object in a separate file because it is used in several places and did not want to be duplicating the definition.