Merge pull request #2080 from alex/test-coverage

Simplified code in the test loaders and improved branch coverage in the x509 tests