Adds error handles and test index *FIX*