Allowing passing of HTML doc to be parsed

Instead of having to call the method from inside a page, we allow the
HTML doc to be passed into the function instead. This way, we can get
document from other sources and parse them.
Also add a test case from sample data.