Math unit tests

Add a minimal set of unit test coverage for the misc_math.c functions.