Entropy helper function and test