Allow test cases to use the directory when only the script name is passed

Fix for #560

Let me know if you think any tests should be added for this.