Fix bug in serializer output and add spec.