fix rgb/rgba color parsing, added appropriate test cases for it

(cherry-picked from 0.3.x)