Updated array functions and tests, bug fixes