Speed up implementation of B-test