Fix exception and test