Refactored tests + little fixes