Fix up exception handling
Use more general mocking so testing is simpler