Fixed #23682 -- Enhanced circular redirects detection in tests.

Please see [#23682](https://code.djangoproject.com/ticket/23682).
Thanks, added.