added tests bug fixes