added some comments, rewrote tests