Refactor long method CertfiicateAuthority#certificate_for