More unit tests; minor bug fix