Refactor test database loading