Add tests for foreach with a ref variable