Refactor Database, table, tests