Url fix

Fix #582 
Fix #559 

- [x] Add tests for get_file_location