[DF-4399] WaitForTask(ID) API implemented and some related errors resolved. Code refactor. Unit test update.