some minor issues fixed, some tests written