Add collator unit tests and some code clean up.