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