Fixed #20392 -- Wrapped TestCase into a class-wide transaction
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