Fixed bug
Added tests
Updated documentation