Improve foreman task pooling

Checking for state is the better approach to verify if the task is
running or not. Also reduced the timeout because this improvement.
Merge pull request #1438 from elyezer/api-task-pooling

Improve foreman task pooling