Adding some persistence logic and test cases