Refactor get test function