Remove Rmath package dependency and fix tests