Improve tests to use Capybara's waiting mechanisms

Related to the failure in #51