bit of cleaning of tests and allow mocking exit

We can now test things in kdm.h that would call `exit`, as we have
a mocked funciton to test with, as we do errno and errmsg.