Factory shop specification/implementation with test in js