Added test code
Added doc comments
better error handling
fixed canonical path broken issue when accessing .html directly