restructure transform code for easier testing
add tests for transformImage
add lots more tests