Finish memory repository code, add test utility functions