debug mode and better test script