Fix tests

This part is db-engine specific. A better test should be written later.