fix factory syntax and some test function