Refactoring - making test more robust