add rmath comparison tests, fix a few small errors