add tests; fix missing check for EINTR