Fixed bug in links from test results web page

Also adding documentation to an increasingly complex section of code.