Fix for documents with existing url

This time the tests pass!

(I also tweaked the tests to ignore whitespace so that they wouldn't choke on windows over line ending differences.)