Added more tests. Fixed bugs in generate_bn