code and test for issue 39
Merge pull request #45 from luciano-fiandesio/issue-39

code and test for issue 39