fixed NPEs during generation when using expect.
Fixed #23

Change-Id: I4d59d22fe3cc1d90512b4a1d9c25c8d2b348a6a7