refactoring to throw exception
adding tests about throwing error
Merge remote-tracking branch 'origin/master'