add download middleware and test