Minor bug fix and more complete tests