Increasing test coverage, fixing a couple of issues in the process