Add a test case and fix the bug by adding missing XML escapes