added preconditions to serializer, check for non-serializable types.
added test