Added tests to reproduce NPE.
Fix NPE that happens when BuildPreferenceJobProperty has no entry.