Update cleanup function and test