Adds more comprehensive test and code