Montgomery: Fix infinite loop for leading zero inputs. Add test.