Fixed #23768 -- Rewrote template tests as unit tests

Do we need to run every single template test with a different value for `TEMPLATE_STRING_IF_INVALID`? Could we just use override_settings in each test that checks for a different value of `TEMPLATE_STRING_IF_INVALID` and have a second assertion?