I had this problem when new chickens were added and realized that they were being kicked off of the roost and they had to sleep in the nesting boxes where they pooped. After many months, I've finally gotten them to sleep on the roost so that the boxes stay clean.
An idea that worked for me: Every night I placed a plastic milk container in the nest boxes and I remove it very first thing in the morning. If you do this for about a week, the habit seems to be broken.
I also had a problem with them laying eggs in the coop, but not in the nesting boxes, so every morning for about 2 weeks I placed a big board on the coop floor. Again they broke the habit and now they're laying in the CLEAN nesting boxes.
Of course I've had a few mishaps ... but basically kicked the habit.