Code reorg: unit tests