Code review: Throw an exception, fix unittests