better handling of conditional features more testing on parser contexts

* gentest.py testapi.c: better handling of conditional features
* HTMLparser.c SAX2.c parserInternals.c xmlwriter.c: more testing
  on parser contexts closed leaks, error messages
Daniel
diff --git a/SAX2.c b/SAX2.c
index b95e555..cf8a615 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -1421,7 +1421,7 @@
     const xmlChar *value;
     int i;
 
-    if ((ctx == NULL) || (fullname == NULL)) return;
+    if ((ctx == NULL) || (fullname == NULL) || (ctxt->myDoc == NULL)) return;
     parent = ctxt->node;
 #ifdef DEBUG_SAX
     xmlGenericError(xmlGenericErrorContext,