Yes, I've experienced this a number of times with my 9 month-old - boy is it frustrating! I definitely think the poops have something to do with it. When ever my lo has to go he is uncomfortable for a number of hours before hand (and has trouble feeding well - breast or bottle). Also, my lo finds it uncomfortable to have a messy diaper and sometimes changing him helps him settle (although I usually end up giving a feed to get him drowsy again - I know, big no-no!). Overtiredness also contributes as this tends to happen when my guy gets to bed too late or has an accumulated lack of sleep. You might want to try an extra early bedtime to see if that helps (I will put mine down as early as 5:45 when he's overtired, although this still may be catnap time for yours. Seeing as both times your lo had a dirty diaper I would definitely think that is the biggest culprit (actually these days I can usually be found with my nose up to his diaper when he wakes in the night, just to be sure it's not that. The fat that it takes so long toget to sleep is probably that because he had a poop and is now lying in it, he has woken fully. It usually takes that long for my lo to get back to sleep when he wakes up fully.
Now, if we could only control when they choose to have their bms!