Modified tests to  be certain which records are being returned.

This is to prevent situations where theses tests seem randomly to fail
because we cannot rely on the order in which PostgreSQL returns its
results.