Unnecessary XML DTD downloads

This is a backport of #1622 to 2.1.x.

I also ported back a bit of testing infrastructure from *master*.