code for R unit testing