improvements and unit test on debug