Fix device middleware tests