Fix bug in handling attributes and add testcases