improve exception handling
make all unit tests work