Db test and fixes. (wip)