Cleanup get_filename tests

and re-order code slightly