If you stop and describe what’s happening, you’ll probably come to the conclusion yourself. Troubleshooting is just about making logical conclusions.
Record the number you’re dialing, and what number you’re dialing from. Write down what happens in each circumstance. Is the behavior consistent and repeatable? If so, record which situations are repeatable. Then record what makes them not repeatable. For example, if you dial from your 555-111-2222 from your cell phone does it behave differently than when you dial from your landline?
If I had to venture a guess, your call flow is probably altering digits for different numbers. For example, maybe you’ve got a route pattern(assuming CUCM, since you mention Unity) that forwards to unity.
Again, assuming call manager, you may want to use the Dialed Number Analyzer tool. You can get there by http:///dna/. (The server needs to have the service enabled.) Once there, you can enter a starting device and the digits dialed.
Do you mean building a new PBX software, or running your own PBX, or creating your own LEC?
Phone numbers are unique, and while they can be mobile, they are tied with original locations and the underlying carriers that route them. You can’t just make them up without going through the FCC first, and ones that already exist but aren’t leased to customers are still owned by LECs. The NANP has specific rules on where numbers route to and how they need to be entered, because it rests on over a century old switching topography. (eg, 212 goes to Manhattan, 312 goes to Chicago, 415 to San Francisco, etc). It would be like building a cabin in the woods, call it 123 Main Street, Faketown, East Dakota 55555-1212 and expect that just by dropping a letter with that address in the mailbox you’ll see it arrive at your cabin later that week.
That said, if you’re looking to be a provider, you’d need to start by partnering with LECs for the area code(s) you’re looking to service and lease numbers from them, just like all the other edge providers do. Or you could try and break into the LEC business, but…I’m guessing that’s not your intent.