Fix tests and add Rakefile task.