Fix #20445 and add some useful comments to the test involved.

Implementation comments in track https://code.djangoproject.com/ticket/20445