Refactored code to force encoding in the loop, removed stale spec tags