Add some testing, but note it is difficult to test units separately.
Also start of work on coarseSample.