Fix regression when serializing quads with a nil graph (i.e. triples).

Added test too.