New unit tests, bug fix