fix issues & added tests