Do not leave tasks in running state

1. Set 'ready' state to task if is in 'running' state after execution.
2. Log final states of such tasks.
Test added.

Related-Bug: #1394495

Change-Id: I53bdbc62de705a57f5411529617e22e769b0ed35
Merge "Do not leave tasks in running state"