DAR-1184: Factory unit tests and some small code fixes