added tests and fixed some issues
fix merge conflict