Fix/indexing

Added tests for indexing, and wait for indexing to finish when refreshing the schema.