Fixes the bug of removing too many zeros, and adds a test for it