adding math tests and fixing implementations