fix powermod problems, add test coverage