major refactor of test code base, with proper helper functions and array accessors