Move dbutil and testutil to database from pkg Rename all "result"
* Refactor layer and ancestry * Add tests * Fix bugs introduced when the queries were moved