refactor test codes