added x509 support and tests ported over