Refactor and add more unit tests for exam page feature.