check task field more finely

1.0.0_wmagent branch vesion of https://github.com/dmwm/WMCore/pull/5422