Added tests, improved documentation