Nil check fix for failing test