Implementation and tests for issue #12