Fix error while having an exception in the Detector, add test for that