factor and add test cases of token