Refactored tests into util and test case