Handle some exceptions, and add some tests