Add tests & several fix