Fix PreferencesManager test.

This is a fix for #6917. The problem was that
`openAndSelectDocument(nonProjectFile` was being called outside of a `run()`
block, so sometimes the nonProjectFile would be open rather than file that
was supposed to be open.