add bag tests and fix some minor issues