Test functions and various R code for thesis work.