memory: Add helper functions and redesign tests