In the footwell of the passenger side is the idle control brain. I have not openend one up but there are some tests you can do on it in the cd's that test for it. That could cause idle problems although, I am not sure what you are getting is a direct effect of that. Idle on these is a beast to diagnose. I assume you have checked all your plug wires and connectors and the rotor and cap.
The other thing to check is the throttle switch and the potentiometer on the air mass flow. do a quick search on those. I have a stall on accelerationand am pretty sure it is my potentiometer.
Spend the time and test test test, you can through money at these and still not fix it.
2005 320 CDI
2006.5 VW Jetta TDI
1991 560SEL (179000 Sold)
1972 280SEL 4.5 ('The Lead Sled' 320000 miles when sold.)
1972 220D (225000 when sold)