Fix for cd context manager if in local mode

When in local mode the with cd() was ignored in Popen. I added a cd wrapper that uses lcd if in local mode, and check the lcd state env variable for Popen's cwd argument