move duplicated code to a function in TestIssuer