Avoid linking against Unix

This fixes the problem and adds a unit test to stop it happening again.