Added tests, fixes.