Adding tests for the global index visitors. Fixing some bugs