modify simple factory pattern code, and add junit support