Remove PSCredential.    Since cred is declaired in line 35, this creates another object, and this cred will be used by test code.