Added tests, fixed compilation errors.