Fix agular/angular.js#1941

Added test also.