Add testing suite and some fixes