added tests and fixed some bugs of gift/graham