R: rewrote test cases using the testthat package.