Code movement

Move some of the code being done in the memory test around to allow it to be used in general by others as generic functions/functors/wrappers...