Added a testcase running some of the functions.
Test now optionally writes out intermediate images.