added tests for local loop and fixed a bug in local array compaction