fixed an indexing error and added some more logic to the test file