Fix bug related to previewing markdown

The problem was the code would try to generate the html for the markdown
no matter which page you were on. This meant that some DOM elements
might be missing and that resulted in an error.

I also discovered that some of the specs weren't actually testing what
said they did. I fixed that.
Add todo