added subarray function and associated tests