[fix] close filedesc in tests
[change] use nix-rust for io operations