Fix device validation in tasks