bug #12 fixed, unit tests written