Fixed issue #4570 (Race conditions when serializing objects to YAML).
The ZAML class was using class variables to keep track of labels and
backreferences while serializing object to YAML. This made it
possible to get ill-formed or incorrect YAML output if two threads
tried to serialize objects at the same time.
Changed to use instance variables of the ZAML class, so there is no
race condition.
Also added some more spec tests to verify that labels are generated
properly.