Fix return value of package factory, fix tests