fix test_to_json_custom_type
clean up some code