Refactor encoding concerns to util_request, out of send and get_states methods