simplify checks in powermod, and add more tests