added `chain` unit test, fixed minor bugs in GC