Add the missing parts of the previous cherry-pick.
Adapt the tests to the latest Jinja2 template changes.
0.17.x does not have `saltenv` support.
Actually run the file.replace unit tests...
Fix the test suite to run the file unit tests
Merge pull request #8672 from s0undt3ch/0.17

Add the missing parts of the previous cherry-pick.