rewrote tests and improved documentation