Some minor improvements and tests