add some bit manipulations
fixed test case