Move stack to HTML rendering into its own method

And add tests for said rendering.