Fix exception catching for malformed parameters, add test