Refactored code. Added test for summary data.