bit of refactoring and fixed tests using the new index: needed thread.sleep to insert data