Added retrieve history function for history collection and some test cases. More test cases needed.