Fix for bug #5, added more unit tests.

Fix for issue #5.
Added more unit tests.