NextGen-Gallery plugin seem to unnecessary pay too much attention to Safe mode. And it does it WRONG! First of all, safe mode is NOT an obstacle if all is configured correctly. I.e. NextGen enforces user to chmod directories to 777 (safe mode is an excuse here), but this it absolutely silly if you are the owner of the directories here. Safe mode will NOT affect mkdir() nor any file operation here and chmod makes absolutely NO SENSE at all!
The server setting Safe-Mode is on !
Please create directory wp-content/gallery/test and the thumbnails directory wp-content/gallery/test/thumbs with permission 777 manually !
Yes, it does use safe mode. So what?! did you try to mkdir() prior complaining? No. Does it work when hacked and removed all this silly checks. Like a charm.
Conclusion: please fix your plugin to complain only when you got a real reason to do so.