Finished tests; fixed bugs found by tests. :)