Update cachematrix.R

My changes to the coursework. Tested using the suggested tests.