fixed overflow bugs in ``_sqrt_mod1``; added tests