Refactoring - Move promises for db functions inside db module in preperation for tests