Fix tests and handle nulls