Fixed test to check before retieving -1 index from array.

Makes phantomjs hang.