Fixes nc to make it more robust and adds more tests.