Add Factory and unit tests