refactored get_fields() and test cases