X509 fixes and testsuite