changed error handling and tests
bug fix