improved logging, fixes #5
improved tests, discovered #6 and #7