Unit tests almost fixed and minor changes