fix the cleanupExpected function

The cleanupExpected was not properly deduping exepected expressions. 
Because the index was incremented even when a duplicate was removed,
 only half of the duplicates were removed. Only incrementing when a duplicate is 
 not found solves this problem.