Handle null or missing values, improve tests