Refactored some tests to take advantage of #20392

Refactored queries tests following #20392

Refactored select_related tests following #20392
Turn some TestCase into TransactionTestCase following #20392
Tests that need to close the connection are not compatible with the concept of a global transaction wrapping the whole TestCase