Refactored yaml test into its own function.

The yaml test logic can now be used for getting a yaml serializer and
deserializer.