some refactors and tweaks in unit tests