Improve JS extraction from HTML. Fixes gh-1942

When there were no lines before a &lt;script> fragment and the previous fragment,
or if there was no previous fragment before a &lt;script> fragment, the parser
would throw. This is corrected.

Thanks to @alex-macaulay for proposing this patch.

This patch re-organizes some of the CLI tests, and corrects behaviour for some
of the `extract` tests.

Closes #1942
go for it, I didn't notice those. I just copy/pasted those tests, only some slight changes to deal with the expected return value from interpret() (because the original return value was expected to be wrong, for reasons unrelated to what was actually being tested)