add some test for math util

I did a bunch of refactoring before merging this leading to lots of conflicts, but I think I got everything in.

Closes #104802