implement tests
add exception handle for empty cards list
slight modification and remove obsoleted funcs
change args to pytest