Fixed logic for usage of list-based entities in to_obj() and to_dict()