engine: fix race in CommandAsyncTask

The race was the following:

1: [thread 1] CommandAsyncTask's constructor reaches the point
   "entityInfo.AttachTask(this)" while the "_multiTasksByCommandIds" still
   contains one task. After this it gets interrupted

2: [thread 2] the CommandAsyncTask.handleEndActionResult is executed in
   meanwhile and issues the
   "_multiTasksByCommandIds.remove(commandInfo.getCommandId());"

3: [thread 1] the first thread continues the execution and calls the
   "entityInfo.AttachTask(this);"

4: [thread 1] the CommandAsyncTask.ConcreteStartPollingTask() is called. It asks
   for the GetCommandMultiAsyncTasks which returns null (because thread 2 have
   deleted it) and fails on NPE on the next line

Fixed by moving all the code which needs to be synchonized to the sync block.

It will not cause any deadlocks because the CommandMultiAsyncTasks.AttachTask
does not use the original _lockObject (nor directly nor indirectly).

Change-Id: Id265df1c1843b976c6f8d65729fd6717c3df3c76
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1015638
Signed-off-by: Tomas Jelinek <tjelinek@redhat.com>