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.
Merge pull request #249 from uwescience/fix-dead-loop-elimination-bugs

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