improve regex and add basic tests