unit testing and found a couple bugs