Factorized the test code