Changed apply.filter function and added tests for apply.command