An example of a choral melody that itself clearly modulates to a different key is the melody of "Allein Gott in der Höh sei Ehr". In the second half of the melody it modulates from the starting key, G major, to the key of a minor. And thus every choral prelude based on this melody has to modulate to a minor in that spot. And every one who knows that melody, knows where this is going to happen, so the modulation is expected, even anticipated and thus not surprising.
In the choral prelude I play here today, Buttstett follows of course the choral melody, and writes the expected modulation to a minor. Nothing surprising there. He saves his ingenuity for other spots in the composition. The second half starts with a sudden f natural, where everyone would expect an f sharp. And after the obligatory modulation to a minor, Buttstett writes another visit to a minor a few bars later, where it is not expected.
All in all, this choral prelude is a very nice example of creativity in constraint. And for those sensitive to it, a model for creativity in corona induced isolation.
Score available here: http://partitura.org/index.php/johann-heinrich-buttstett-allein-got-in-der-hoh-sei-ehr/