Using the HtmlUnit API with JSFUnit has a section on working with multiple windows. That will take care of the client side.
server.getCurrentViewID() should work as long as the new window is using the same HttpSession. I took a look at the JSFUnit test suite and I don't have any tests for the server side in that situation. Please let me know what you find.
A sample if someone need
//link on my home page
<a id="lp" href="/pages/pub/lostpwd.jsf" target="_blank">Lost password</a>
WebClient webClient = jsfSession.getWebClient();
HtmlPage firstPage = webClient.getPage("http://localhost/");
//id of the link
HtmlAnchor anchor = firstPage.getHtmlElementById("lp");
Page secondPage = anchor.click();
//id of button on second page "/pages/pub/lostpwd.jsf