Test middleware