add testthat both for testing and illustration