Added a unit test and made beautified output.