add cardType function and some tests