added test and fixed one small issue