refactored to reduce amount of code duplication between checkUrl and checkHtmlFile
misc formatting changes