Changed code and unit tests