* Avoid infinite loops, and double roots when root certificate was already part of chain. * Refactor tests for readability.