fixed restrict mode and added tests