fixed problem 'Invalid argument', and added a test that reproduce the error