Optimisations for weight and sample size testing