cleanup math, extend test