refactor out Array, improvements, tests