More detailed exception handling
unittests added and modified for more detailed exceptions
examplecode modified