Fixes Issue #26 (with unit tests)