Fixed #23768 -- Rewrote template tests as unit tests

`from django.utils.six import range` for consistent testing on py2/3 (or `list(range(5))` to test what's being tested on py2 now).