fixed problem 'Invalid argument', and added a test that reproduce the error
Merge pull request #28 from liuggio/master

Solved problem reported