Solution for assignment, with some testthat unit tests in test_cachematrix.R