Adds unit test for some core/cards.py function.

Mainly for education & training purposes, but will be nice for refactoring.
Expands unit tests. Updates cards.py to pass unit tests and cleans up
code.