added cwd parameter, made timeout configurable