Added some tests, fixed bugs.
Added some tests, fixed bugs.