Fix removal of text node and run tests

In Chrome and Firefox, the prefix was not being removed after the list was
created. This PR fixes that.

Some of the tests are failing in Firefox still, but AFAICS this is a separate
issue (will create an issue).
This still feels hard to read. Maybe could just have if-ifelse-else below?