Bugfix. TemplateBase.WriteTo uses wrong Writer which leads to wrong order in output.

While trying to pass inline templates into included templates I noticed the output order being wrong. Everything which needs encoding is output before the literal parts of the template.

This commit contains the fix and a unittest to test the solution.