Fix DB API tests depending on the order of rows

A few DB API tests depends on the specific order of returned rows
in SQLite (i. e. ORDER BY is not specified for DB queries). This
order can be different when running tests on PostgreSQL or MySQL,
so the tests must be fixed to not depend on it.

Blueprint: db-api-tests-on-all-backends

Change-Id: Ibc0094edf70b03264e78878ebb6a6bdcb1fb942d
Merge "Fix DB API tests depending on the order of rows"