modularized the test code