The size of the nestbox can be a factor as well. If the nestbox is too large for the breed of chicken you keep, it encourages them to hang out inside it, and they walk on the eggs and get them dirty.
If a nestbox is the right size, it will only be used for laying eggs (and occasional brooding).
If a nestbox is the right size, it will only be used for laying eggs (and occasional brooding).