fixed all ref bugs in tests