Fix encoding rules in _encode_escape_chars.
Escape <text:s> if found within template tags in _unescape_entities.
Updating test with new API.