ENV vars: improve test case, provide working escaping.

- change test app into a template file
- make test app and CMake side obey a common environment variable prefix,
  to collect the set of env vars and, most importantly, being able to add
  a new env var case in one central location
- write out an "expected result" file and do a CMake -E compare_files
  on expected vs. actual result files
- document and work around existing surprising CMake escape issues
- add escaping for affected parts of batch env var content