migrated bagtests from test.cpp code to CommonTests_bagtests - complete (but little tested)