Pass ClassGenerator instance instead of boolean

We should pass the ClassGenerator instance value (instead of the boolean returned by instanceof) to the setClass method call. 

Added testCreateFromArrayWithClassInstance which directly addresses issue 4006, also added testCreateFromArrayWithClassFromArray since it was not there