Added further tests for array factory. Refactored array factory.