Improved exception handling in test
Fixed checkstyle warnings