Fix loop test bug