libhtml: Add tests, support &#X

Add a bunch of tests taken from cpython's html module, along with a
couple of other homegrown ones.

Add support for &#X123; entities, with the capital X, which was
forgotten before.
libhtml: Fix edge case in entity parsing

When a named entity is aborted, we need to backtrack to the longest
prefix that doesn't require a semicolon.