fix cardForm unit tests and refactor class