reversebinary test and code refactoring.