Add test and some refactor in binary class