Prevent the deletion of files that are used as unit test comparison

This patch fixes a problem that I introduced when I ported the app template and file template wizard to KF5. The problem in the unit test was, that the wrong working directory was used and the auto cleanup accidentaly deleted the wrong files (These files were used as comparision for the test result).

Now the unit test creates and uses an own directory.

REVIEW: 119985
Fix 'destroyed locked mutex' warning

The problem was that 'internalMutex' in foregroundlock.cpp was still
being locked.

Not sure if this can cause any harm, thus putting it on review board
first. Please comment.

REVIEW: 120035