Refactored the task history support added by JoeEnnever

Refactoring mainly to remove all try/except guards

Also added a unit test for the task history part (although not testing the web interface integration)