Fix infinite loop problem in iedit-rect-mode
Also add a new test case