Updated test_utils.py and its helper and utils.py

Updated the test cases in test_utils.py except for location testing.

Updated utils.py to reflect some of the errors detected after updating
the test cases.