Can't you just turn the cert into a byte array using the export method? I'd rather have the same method use for both real and test code, rather than constructing it a different way for each.