The headers already sent thing is a common problem. There should be an explanation if you click on the highlighted text in your, or this, forum post. If, as I think you suggest, you've already ruled this out, then there was fix put into CVS recently that fixed a cookie problem with the Login Block, maybe that is the cause.
My answer to your original question is the same as Howard's i.e. don't do that. But I think Howard got the idea that you were running two instances on the same machine (a perfectly normal thing to do, though most people give them different URLs). In fact, it seem that you are running them on two different machines. The question then is why you don't give the two machines different names e.g. www.yourmoodle.com and test.yourmoodle.com and leave both on port 80.
Hope that helps, at least a little bit.