test: fix ineffective error tests
Fix tests whether errors are thrown correctly because they are successful when error doesn't get thrown.
fix https://github.com/nodejs/node/issues/26385
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
commit message follows commit guidelines