added tests and changed style a little