Fixed waitTask method wrongly detecting errors
Fixed tests