Refactor utility functions for setup/teardown of DB