[Cleanup] Code cleanup after code review

- Don't initialize result in task creation.
Avoid specific cases. It doesn't make the code more readable, nor smaller.

- if/else cleaning.
Make default action in if statement, and error management in else statement.
Most common usage.

- Factorize code.
Move same function call from each switch/case, outside the switch.
Reduce code.

Signed-off-by: Ludovic Ferrandis <ludovic.ferrandis@intel.com>