test: fix test isolation and remove hardcoded /bin/true path dependency

Replace bare os.chdir() calls in test_api.py with monkeypatch.chdir() so each
test restores cwd on teardown, preventing order-dependent failures in CI.

Replace hardcoded /bin/true and /bin/false in test_legacy_cli with
sys.executable -c "" and sys.executable -c "raise SystemExit(1)" so the test
works on NixOS and any platform where /bin/true is absent.
