Fix unresolved reference of System.Threading.Tasks and limit the usage of Debug.Fail