Fix return as file from plugin
Better testing, take care of file extension