refactor testing logic.