Added tests and other good things to lib.math.