bugfix pattern matcher for bug #1025

I'm hoping that this fixes bug #1025.  I tested this by pulling today's branch 
```
git pull git@github.com:/shujingke/opencog CrashRepeat
```
and merging these fixes.  Starting the cogserver and then doing  loadmodule opencog/embodiment/Learning/LearningServer/libTestPatternMinerAgent.so  seems to run to completion without errors or asserts.