Handled exceptions in fit; Added tests