[JENKINS-19494] Added tests for handling newInstance.