Fix NPE

Fixes https://github.com/appium/appium/issues/628