Refactoring tests by adding common test util functions