Improve confidence interval test code