Make tests for system call failures a little more robustly
Add an explicit cast to int in lookup_shadow