unit tests and refinements