new test dist_mem, some code cleanup