moved most of methods to helper class, so that testing them is easier.