fixed a memorizing bug when a specific polynomial modulus is specified to FiniteField

Also fixed a problem with computing inverses: checking for 1 instead of
a unit.