fix and test issue #24 @brianr