Some of the essential fixes and refinements proposed by algernon have been added (still TODO: avoid API breaks; flexible SSL support testing; some additional code refactorization)