Added tests. Fixed bugs.