Reordered setUp code in prefetch_related tests.

This allows these tests to run on databases that reject duplicate NULL
values in unique fields e.g. SQL Server.

Forward port of 4fb50a9a from stable/1.7.x.