updated to reflect PR changes requested and improvements
added test to prove new changes work