comitting some old changes from ndw-workhorse, modified bonferroni_test with extra parameter Nsurr