Fixes #18. Added unit test.