fix some misplaced set_dir()s

fixes part of #7284
fixes #7288
fixes one of #7287

Signed-off-by: Mloc <colmohici@gmail.com>
Merge pull request #7296 from Mloc/bs12-arrgh

fix some misplaced set_dir()s