Refactor exam unit tests and initial attempt to make some codes reusable.