Html5lib unicode fix

Creating a PR for @harig's fix (which I guess I made messy with a merge... sorry).

This branch passes the few tests that we have, but I wonder if we can add a small test or two in addition to the fix. Any ideas?