Fix toMod' to not truncate the result

Change toMod' to first take the modulus and only then convert from one Integral to another.

Otherwise, if you have a large Integer  (say 2^100 :: Integer) and you convert it with the current toMod' into Int/10 then you get a wrong result. The number first gets truncated to fit into an Int, and then we take its remained mod 10.