adding tests and improvements from them
Merge branch 'code' of github.com:kyzhai/SMURF into code