Fix invalid exception + test