refactoring, new tests to issue #35.