Moved adding certificate to trusted certs to avoid possible race condition for #1393