Fix marking a task as PENDING while it is still running - in the history DB
Update the task in the historydb only if there was a change in status, prevent multiple updates of the same status
Refine the check for writing into the history db. If the status is PENDING - write no matter what the value of task.status is - since it's the default value
Merge pull request #344 from rantav/fix-historydb-repending

Fix marking a task as PENDING while it is still running