Added a test and implemented Lance's comments