test: Add tests for issue #12223, "drop allowed while active borrows

still in scope".

This issue was fixed by PR #12828 and #5781. All that was left was to
add tests.

Closes #12223.