dead-loop-elimination: add a test and fix two bugs

1) we need to track inner-loop definitions from the first line of the loop
2) i+1 is not necessarily the next statement if we delete multiple loops.