Slight code cleanup
Add tests