Database Test + Refactoring