Refactered Code To Use Templates

This enables us not just to test html text but by using a template
all we have to check is that correct template is used.