You should probably avoid using global variables (variables declared outside the scope of a function). If you need access to the variable in another part of the script, then it would probably be wise to move the Unit declaration in the ScriptGlobal struct (or whatever the struct is called that gets setup in GetSaveRegions). If you're not using it elsewhere, then just move the Unit declaration into the function.
I believe DoBuild doesn't work with mines. At least not properly. I vaguely remember you can use build coordinates with an offset, like where ConVecs move when building a structure, but this was a bit glitchy. I think the proper way to build a mine, is to record the mine in a building group, and give the building group enough units to go and build the mine itself. I'm pretty sure someone else has posted something about this. You can probably find something useful on the forum if you do a search and wade through some of the results.