revise exit logic of memory server
add test case