Add stacktrace to ParseError

Fixes #854. Also clean up the parse error test a little, while adding a .stack check.
@codler did you try the procedure I mentioned above?

Anyway, it's related to switching between document modes, so we are probably safe to use it.