Fixed variable loop shadowing in test