Bug 1431

Test added and some errors fixed