Refactored tests to make them more robust.