Added more tests and also added code that uses util methods to figure out pivot