Adopted changes from https://github.com/kif-framework/KIF/issues/421, migrated to Swift 1.1