Fix tests so that they work with non-empty db