Calculating the test statistic