xdg-terminal-exec: Move more code into functions
Created by: fluvf
See commit messages for details
Now that most functionality is in separate functions, tests could be written for each individually Should make for a simpler and more comprehensive set of test