Implement functions to sync database and fix test.