tests: improve error handling in test_jvm