Refactored db funcs and types back into a package, otherwise code coverage breaks