architecture improvement + unit tests + cs fix