remove print in tests.
small code simplication.
fix memory leak with allow_gc=False