fixed bugs, test class for NB