Update t-test script and fix bugs