Allow Database class to be mocked, tidy up, documentation