format code and fix the wrong useage of scala-test excpetion intercept