Fixed issue #10 and added unit tests.