Optimises the array helper and adds unit tests.