Refactoring test_db