Testing for a unit root in panels with dynamic factors