[Safe Refactor] Add some unit tests.