Due to delayed expansion enabled, the bang would get lost and test! would get interpreted as test. Fix this by disabling delayed expansion before running the command.