Increased coverage and fixed a few bugs on the way