[1.6.x] Fix #21185: Added tests for unescape_entities.

Also fixed a py3 incompatibility.
Thanks to brutasse for the report.

Backport of 3754f4ad410640382f9fe25073da03009cdc2ea3 from master.