Fix #1193: Regression: Invalid XHTML in shiny exception template when first line in stack frame is HTML. Adds test for this and other issues. Also refs #926, #1150 and #1152