add select/filter/ensure middlewares and tests