new unit tests & fix discovered bugs