added tests and modulified it