added tests, worked on subsample routine