fix regex and add test for it
minor code cleanup