Check for perfect power before using `ecm`
Add a test
Fix test failures