Refine code, add more unit tests

1 job for develop-CRPSS
in 8 minutes and 23 seconds, using 0 compute credits, and was queued for 3 seconds