A judge can sign an order changing a name for just about ANY reason. That in and of itself doesn't over-rule ACTUAL establishment of paternity via DNA testing. The court can, based on his belief, the fact that you two were playing house together during the time in question, and aided by the fact that you did give the child HIS last name, order you to submit to the test (in fact that's way MORE than they need to order the test). If it turns out that he's the father, you can count on him getting some kind of visitation/custody, as well as a child support order. (And don't make the common mistake of thinking that you can withhold visitation if he's not paying - they are two separate issues and that won't fly.) You two will have to work with the court to come to some arrangement as far as visitation (and the travel and other costs associated) since you're in separate states. If he's willing to pursue the matter, you can pretty much count on him being at least some part of the child's life until the child reaches 18. If you had been married to your ex, he would have been presumed to be the father, but even so, if a paternity test establishes otherwise, you'd be back in the same boat. The court isn't likely to be happy that you conspired with your re-ex in trying to circumvent the potential bio father's access to the child - with both of you pretty darn sure that the re-ex couldn't have been the father (you weren't even in the same STATE when the child was conceived) and if the bio father gets a kick ass attorney, that course of action is certainly NOT going to be viewed in a favorable light by the court. Nor will your re-ex's offer to knowingly lie on a legal document saying he's the father lead to any possible outcome with a positive spin on it.
Courts have been known to re-assign custody altogether when one parent tries to carve the other parent out of the picture, and it looks like a lot of that going on here. You can't change the events up to this point, but from here on out, it's in your best interest and the child's best interest if you try to work WITH the situation, and not against it. A really good (and cheap, fortunately) book on the topic is
Joint Custody With A Jerk
I strongly recommend that you check it, or something like it, out ASAP so that you can start getting used to the idea of bio dad being in the picture where this child is concerned (assuming that the paternity test establishes him as the father).