XDS now runs in different threads
Fix bugs. TODO: chdir in exec does not work it is launched in a thread.
Added unit test