Expose errors through an nn_errno function

Also simplify some of the tests as now no other syscalls are gonna clobber our
errno anymore. 

Cc: @borisz