Corrected output for doctest and reformatted long lines.
Added more unit tests.