modified code to prevent null ref exceptions due to different test runners