checking that bad input throws the correct exceptions