refactor validate test to other function