Fix for NULLPointerException found in unit tests