fix nil bug and create new test to produce it