fixed array merging bug + added tests for array merging bugs