Properly wrap waiting for agent logging

Signed-off-by: Maria Shaldibina <mshaldibina@pivotal.io>