Added test and several comments