Add tests from "Review of CAS mathematical capabilities" (#694)

This is continuation of PR#1934 which stalled. Fixed code quality issues and merged in `master` branch.