improvements to formatting of html returned by error middleware