added tests, fix Apply