Fix _get_range and support tokens with key_count