Add job array state test functions

Add functions to test the state of a job array, for example
test_job_array_pending() returns true if ANY task of a job array
is pending and test_job_array_completed() returns true if ALL
tasks of a job array are completed.
Job array dependency refinement

Job array dependency based upon state is now dependent upon the state of
the array as a whole (e.g. afterok requires ALL tasks to complete
sucessfully, afternotok is true if ANY tasks does not complete successfully,
and after requires all tasks to at least be started).