TRUNK-3912 

Task does not turn off automatically when uninstalling the module associated with it
I think the better option would be to check if the class was loaded from the module's class loader as below:

Context.loadClass(task.getTaskClass()).getClass().getClassLoader().equals(ModuleFactory.getClassLoader(module))

Otherwise, this can fail for modules where one module's id is a substring of another e.g org.openmrs.webservices and org.openmrs.webservices.rest19ext