Added constructor that accepts a DB object, to facilitate mocking.