fixes and tests (issue #15)