bag optimization & tests