Fix performance and correctness of finding the <head> and </head> tags
Updates following code review
Merge pull request #6 from shartrec/master

Fix performance and correctness of finding the <head> and </head> tags