restructute the testing code