refactored a smidge, fixed and added to tests