Added migration for database and tests. Also fixed errors