add unit tests/fix failures