fixed some problems the unit tests revealed