add test and fix bug in checking attribute in onAttach